const path = require('path');
const webpack = require('webpack');
var node_modules = path.resolve(__dirname, 'node_modules');
var pathToReact = path.resolve(node_modules, 'react/index');


var proConfig = {
    devtool: 'source-map',
    entry: {
        // "login-reset-success" : "./static/src/js/global/login-reset-success.js",
        // "resetpwd" : "./static/src/js/global/resetpwd.js",
        "vendor": ['react', 'react-redux', 'react-dom'],
        "contacts": "./static/src/js/associator/contacts.js",
        "settings": "./static/src/js/settings/dingstore.js",
        "ordinary": "./static/src/js/ordinary/ordinary.js",
        "tasks": "./static/src/js/tasks/dingstore.js",
        "dashboard": "./static/src/js/dashboard/dingstore.js",
        "workflows": "./static/src/js/workflows/dingstore.js",
        "profile": "./static/src/js/profile/dingstore.js",
        "not-found-error": "./static/src/js/errors/not-found-error.js",

        // "login-forgot-success": "./static/src/js/global/login-forgot-success.js",
        // "login-forgot": "./static/src/js/global/login-forgot.js",
        // "internal-error": "./static/src/js/errors/internal-error.js",
        // "maintainance": "./static/src/js/errors/maintainance.js"

    },
    output: {
        path: path.join(__dirname, 'static/dist/js/'),
        filename: "[name].js",
        chunkFilename: '[name].js',
        publicPath: '/dist/js/'
    },
    resolve: {
        extensions: ['', '.js', '.jsx', '.scss']
    },
    resolve: {
        alias: {
            'react': pathToReact
        }
    },
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                include: path.appSrc,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query: {
                    cacheDirectory: true,
                    presets: ['react', 'es2015'],
                    plugins: [["import", { libraryName: "antd", style: "css" }]]
                }
            },
            { test: /\.css$/, loader: 'style-loader!css-loader!postcss-loader' },
            { test: /\.less$/, loader: 'style-loader!css-loader!postcss-loader!less-loader' }

        ]
    },
    plugins: [
        new webpack.BannerPlugin('Copyright by wulongbin@parllay.cn!'), // 版权声明
        new webpack.optimize.OccurrenceOrderPlugin(), // 为组件分配ID
        // 压缩JS
        new webpack.optimize.UglifyJsPlugin({
            output: {
                comments: false
            },
            compress: {
                warnings: false
            }
        }),
        new webpack.optimize.CommonsChunkPlugin({
            // 提取公共代码
            names: ['vendor'],
            filename: 'vendor.js'
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('production')
            }
        })

    ]
    
};



module.exports = proConfig;